package threadLearn;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
 * 加锁释放锁等价代码
 * @author 12609
 *
 */
public class SynchronizedToLock {
	
	Lock lock = new ReentrantLock();
	
	public synchronized void method1() {
		System.out.println("I am sychronized...");
	}
	public void method2() {
		lock.lock();
		try {
			System.out.println("I am lock...");
		} finally {
			lock.unlock();
		}
	}
	
	public static void main(String[] args) {
		SynchronizedToLock st = new SynchronizedToLock();
		st.method1();
		st.method2();
	}

}
